﻿using UnityEngine;
using UnityEngine.UI;

public class ExtraProgress : MonoBehaviour
{
    public float target;

    public float current;
    private Image progressImage;
    public float maxWidth;

    public float Current
    {
        get { return current; }
        set { current = value; UpdateUI(); }
    }

    private void Awake()
    {
        progressImage = GetComponent<Image>();
    }

    private void UpdateUI()
    {
        if (target == 0) return;

        float progress = Mathf.Clamp(Current / target, 0, 1);
        progressImage.fillAmount = progress;
    }
}
